package lol.clann.minecraft.springboot.api.bukkit.utils;

import javax.script.CompiledScript;
import java.util.Map;

/**
 * 提供js脚本支持
 *
 * @author pyz
 * @date 2019/5/22 12:18 AM
 */

public interface JSUtils {

    CompiledScript compileScriptFile(String file);

    CompiledScript compileScript(String javascript);

    /**
     * 脚本中常驻变量
     * logger       lol.clann.minecraft.springboot.api.bukkit.utils.JSUtils
     * random       java.util.concurrent.ThreadLocalRandom
     * playerUtils  lol.clann.minecraft.springboot.api.bukkit.utils.PlayerUtils
     * server       org.bukkit.Server
     * scheduler    org.bukkit.scheduler.BukkitScheduler
     * plugin       org.bukkit.plugin.java.JavaPlugin
     *
     * @param scriptPath
     * @param bindings
     * @return
     */
    Object evelScriptFile(String scriptPath, Map<String, Object> bindings);

    /**
     * 直接执行脚本
     *
     * @param script
     * @param bindings
     * @return
     */
    Object evelScript(String script, Map<String, Object> bindings);

}
